<?php
/**
 * Created by PhpStorm.
 * User: Kyle
 * Date: 2019/7/17
 * Time: 15:17
 */

namespace app\common\model;


use think\Model;

class Topic extends Model
{
    protected $pk = 'topic_id';

    /**
     * @var array
     * 分类
     */
    public static $_type= [
        1=>'爱情测试',
        2=>'财富测试',
        3=>'两性测试',
        4=>'趣味测试',
        5=>'社交测试',
        6=>'性格测试',
        7=>'职场测试',
        8=>'综合测试',
    ];

    public static $_sex = [
        '男'=>'male'
        ,'女'=>'female'
    ];

    public static $_constellations = [
        '水瓶座'=>'水瓶|Aquarius'
        ,'双鱼座'=>'双鱼|Pisces'
        ,'白羊座'=>'白羊|Aries'
        ,'金牛座'=>'金牛|Taurus'
        ,'双子座'=>'双子|Gemini'
        ,'巨蟹座'=>'巨蟹|Cancer'
        ,'狮子座'=>'狮子|Leo'
        ,'处女座'=>'处女|Virgo'
        ,'天秤座'=>'天秤|Libra'
        ,'天蝎座'=>'天蝎|Scorpio'
        ,'射手座'=>'射手|Sagittarius'
        ,'摩羯座'=>'摩羯|Capricorn'
    ];


    public function getTopicInfo($id){
        return self::get($id);
    }

    public function questions(){
        return $this->hasMany('TopicQuestion','topic_id','topic_id')
            ->where(['is_deleted'=>0])->order('question_sort','asc');
    }

    public function answers(){
        return $this->hasMany('TopicAnswer','topic_id','topic_id')
            ->where(['is_deleted'=>0]);
    }
}